﻿
using System.Windows;
using System.Windows.Media;

namespace Red.Core
{
    /// <summary>
    ///     Bunch of methods to operate on geometries (useful while working with DrawingContext)
    /// </summary>
    public static class GeometryHelpers
    {
        /// <summary>
        ///     Creates polygon from given points
        /// </summary>
        public static Geometry CreatePolygon( params Point[] points )
        {
            StreamGeometry streamGeometry = new StreamGeometry();
            using ( StreamGeometryContext geometryContext = streamGeometry.Open() )
            {
                geometryContext.BeginFigure( points[0], true, true );
                for ( int i=1; i < points.Length; ++i )
                    geometryContext.LineTo( points[i], true, true );
            }
            return streamGeometry;
        }
    }
}